<script setup>
const props = defineProps({
  conf: {
    type: Object,
    default: () => {}
  },
  formData: {
    type: Object,
    default: () => {}
  }
})

defineExpose({

})

function getFormAttrs() {
  return props.conf.formAttrs || {}
}

function getOuterAttrs(outerAttrs) {
  return outerAttrs || {}
}

function getInnerAttrs(innerAttrs) {
  return innerAttrs || {}
}
</script>

<template>
  <el-form v-bind="getFormAttrs()">
    <el-form-item v-for="item in conf.formItems" :key="item.id" v-bind="getOuterAttrs(item.outerAttrs)">
      <template v-for="(_, slotName) in $slots" #[slotName]>
        <slot :name="item.field + '_outer_' + slotName" />
      </template>
      <!-- 单行文本 -->
      <el-input v-if="item.fieldType === 'String'" v-model="formData[item.field]" v-bind="getInnerAttrs(item.innerAttrs)">
        <template v-for="(_, slotName) in $slots" #[slotName]>
          <slot :name="item.field + '_inner_' + slotName">
            <Component v-if="item.componentInstance" :is="item.componentInstance"></Component>
          </slot>
        </template>
      </el-input>
    </el-form-item>
  </el-form>
</template>

<style scoped>

</style>
